﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace LearnDrive
{
    public partial class frmMsg : Form
    {
        public string msg;
        public int second;
        public bool isexitapp=true;
        public frmMsg(string m,int s,bool e)
        {
            InitializeComponent();
            msg = m;
            second = s;
            isexitapp = e;
            this.lblmsg.Text = msg;
            this.Width = this.lblmsg.Width + 10;
        }

        private void frmMsg_Load(object sender, EventArgs e)
        {            
            if (second > 0)
            {
                timer1.Enabled = true;
            }
            this.TopMost = true;
            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            second--;
            if (second < 0)
            {
                timer1.Enabled = false;
                timer1.Stop();
                if (isexitapp)
                {
                    Application.ExitThread();
                }
                else
                {
                    this.Close();
                }
                this.TopMost = true;

            }
        }

        private void frmMsg_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (isexitapp)
            {
                Application.ExitThread();
            }
            else
            {
                this.Close();
            }
        }
    }
}
